package cn.kgc.springcloud.client;

import cn.kgc.springcloud.entity.Order;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author 课工场
 * @date 2024/4/28
 * @description   维护user模块调用order模块的请求地址
 */
//声明目标服务在注册中心的注册名称   后续可以根据注册名到注册中心拉取通信节点  默认使用轮循策略
@FeignClient("ORDER")
public interface OrderClient {

    @RequestMapping("/order/m1")
    String method1();

    /*
    *   通过openfeign实现服务间通信有参数携带时  需要声明参数传递方式
    *    /order/m2?uid=10     -> queryString  @RequestParam
    *   /order/m3/{uid}      ->  restful
    *
    * */
    @RequestMapping("/order/m2")
    String method2(@RequestParam("uid") Integer uid);


    @RequestMapping("/order/m3/{uid}")
    String method3(@PathVariable("uid")  Integer uid);


    // /order/m4?id= ''  & productName= ''
    @RequestMapping("/order/m4")
    String method4(@RequestParam("id") Integer id,@RequestParam("productName")String productName);

    //发送请求时 会将对象转换成json格式进行传递
    @RequestMapping("/order/m5")
    String method5(@RequestBody Order order);


    // /order/m6?ids=1&ids=2...
    @RequestMapping("/order/m6")
    String method6(@RequestParam("ids")Integer[] ids);


    @RequestMapping("/order/m7")
     List<Order> method7(@RequestParam("uid") Integer uid);

    @RequestMapping("/order/m8")
    Order  method8(@RequestParam("id")Integer id);
}
